package com.andy.controller.util;

import com.andy.controller.pojo.Result;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ResultUtil {

    public static Result create(Object o){
        //创建出参
        Result result = new Result();
        result.setMessage("");
        result.setStatus("1");
        //把出参对象转为json
        try {
            ObjectMapper om = new ObjectMapper();
            String bodyJson = om.writeValueAsString(o);
            result.setResultJson(bodyJson);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return result;
    }
}
